<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
</head>
<script type="text/javascript">
var tradeid="";
var tradeCode
function createTrade(){
	window.location.href="${ctx}/appFrameTrade/jumpCreatePage?appid=${appid}";
}

function rowClickAfter(rowIndex,curTradeId, curTradeCode) {
	tradeid = curTradeId;
	tradeCode = curTradeCode;
	var  arrId = document.getElementsByName("check");
	arrId[rowIndex -1 ].checked=true;
}

function deleteTrade(){
	if(p_del()){
    $.ajax({
        url:"${ctx}/appFrameTrade/delAppTradePrivate?tradeid="+tradeid,
        type: "POST",      
        dataType:"json",
        async: false,
        success: function(data) {
        	if(data.flag>0){
	            alert("删除成功！");	
	            window.location.reload();
        	}
        },
        error: function() {
          alert("error");
        }
      });
	}
}


function p_del() { 
	var msg = "您真的确定要删除交易["+tradeCode+"]吗？\n\n请确认！"; 
	if (confirm(msg)==true){ 
		return true; 
	}else{ 
		return false; 
	} 
} 

function updateTrade(){
	if(tradeid == ""){
		alert("请先选择要编辑的交易!");
		return;
	}
	document.getElementById("linkPage").href = "${ctx}/appFrameTrade/jumpEditPage?tradeid="+tradeid;;
	document.getElementById('linkPage').click();	

}
</script>
<body topmargin="0">
<div class="panel panel-default">

   <div class="panel-body">
		<form class="form-horizontal" role="form" method="post" action="${ctx}/appFrameModule1/appFrameTradeList.do?appid=${appid}">
                <div class="form-group">
                          <label class="col-xs-1 control-label" for="qtcode">交易码</label>
                          <div class="col-xs-3">
                             <input class="input-sm form-control" id="qtcode" name="qtcode" value="${qtcode}" type="text"/>
                          </div>
                          <label class="col-xs-1 control-label" for="qtname">交易名称</label>
                          <div class="col-xs-3">
 									<input class="input-sm form-control" name="qtname" id="qtname" value="${qtname}" type="text" />
                          </div>
                          <div class="col-xs-3">
                          	 <button type="submit" class="btn btn-default btn-sm" >&nbsp;&nbsp;查&nbsp;&nbsp;询&nbsp;&nbsp;</button>                          
                          </div>
                </div>
		</form>
	</div>
</div>                
      			<div class="op-btn">
					<input type="button" class="btn btn-default" value="创建交易" onclick="createTrade()" />
					<input type="button" class="btn btn-default" value="删除交易" onclick="deleteTrade()"/>
					<input type="button" class="btn btn-default" value="编辑交易" onclick="updateTrade()"/>
					<a id="linkPage"  target="_blank"/></a>
				</div>	
				<macms:table dataListName="atpList">
					<macms:html id="ch" label="选择" innerHtml="<input type=\"radio\"  name=\"check\" value=\"15\">"></macms:html>
				    <macms:text id="TRADE_ID" align="center" label="交易标识"></macms:text>
					<macms:text id="trade_code" label="交易码"></macms:text>
					<macms:text id="forward_channel_id" align="center" label="转发渠道标识"></macms:text>
					<macms:text id="trade_name" label="交易名称"></macms:text>
					<macms:text id="page_id" align="center" label="归属页面"></macms:text>
					<macms:text id="is_check_token" align="center" label="检查是否有效会话"></macms:text>
					<macms:text id="is_check_device" align="center" label="检查是否同一台设备"></macms:text>
					<macms:text id="is_check_network" align="center" label="检查网络是否变更"></macms:text>
					<macms:text id="is_use_baffle" align="center" label="是否使用档板"></macms:text>
				</macms:table>

</body>
</html>
	<script language="javascript">
    var preRow = null;
	$('tbody tr').bind('click', function() {

		var rowIndex = $(this).prevAll().length+1;
		if(rowIndex <1) return;
		
		if(preRow != null){
			preRow.removeClass("active");
		}
		$(this).addClass("active");
		preRow = $(this);
		
		// 行单击后事件(传入行号，交易ID,交易码)
		rowClickAfter(rowIndex,
				$(this).find("td").eq(1).text(),
				$(this).find("td").eq(2).text());
		
	});
		
	</script>
